package com.farm.wcp.wsch;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.wsch.client.domain.WDocVirtualField;
import com.wsch.client.domain.WDocAppDic;
import com.wsch.client.domain.WDocAppDic.ABLETYPES;
import com.wsch.client.domain.WDocAppDic.LIKETYPES;
import com.wsch.client.domain.WDocAppDic.SUMABLES;
import com.wsch.client.domain.WDocAppModel;
import com.wsch.client.domain.WDocField;

public class WschConfigs {

	/**业务模型
	 * @return
	 */
	public static List<WDocAppModel> getAppModels() {
		Map<WDocVirtualField.TYPES, WDocVirtualField> baseFields = new HashMap<WDocVirtualField.TYPES, WDocVirtualField>();
//		TITLE:标题,
		baseFields.put(WDocVirtualField.TYPES.TITLE,
				new WDocVirtualField("标题", WDocVirtualField.TYPES.TITLE, "$[TITLE_HL]"));
//		CONTENT:正文,
		baseFields.put(WDocVirtualField.TYPES.CONTENT,
				new WDocVirtualField("正文", WDocVirtualField.TYPES.CONTENT, "$[CONTENTS_HL]"));
//		IMG:展示图,
		baseFields.put(WDocVirtualField.TYPES.IMG,
				new WDocVirtualField("预览图", WDocVirtualField.TYPES.IMG, "download/Pubfile.do?id=$[IMGID]&secret=$[IMGSECRET]&sizeType=MIN"));
		
//		TAG:标签,
		baseFields.put(WDocVirtualField.TYPES.TAG, new WDocVirtualField("标签", WDocVirtualField.TYPES.TAG, "$[TAG_HL]"));
//		TIME:时间,
		baseFields.put(WDocVirtualField.TYPES.TIME,
				new WDocVirtualField("时间", WDocVirtualField.TYPES.TIME, "$[ETIME]"));
//		AUTHOR:作者,
		baseFields.put(WDocVirtualField.TYPES.AUTHOR,
				new WDocVirtualField("作者", WDocVirtualField.TYPES.AUTHOR, "$[AUTHOR]"));
//		CATALOG:类型分类
		baseFields.put(WDocVirtualField.TYPES.CATALOG,
				new WDocVirtualField("类型分类", WDocVirtualField.TYPES.CATALOG, "$[TYPETITLE]"));
		List<WDocAppModel> models = new ArrayList<WDocAppModel>();
		{

			Map<WDocVirtualField.TYPES, WDocVirtualField> appFields = new HashMap<WDocVirtualField.TYPES, WDocVirtualField>();
			appFields.putAll(baseFields);
//			OLINK:原文地址,
			appFields.put(WDocVirtualField.TYPES.OLINK,
					new WDocVirtualField("原文地址", WDocVirtualField.TYPES.OLINK, "classweb/Pubview.do?classid=$[APPID]"));
			models.add(new WDocAppModel("课程", "CLASST", 1, appFields));
		}
		{
			Map<WDocVirtualField.TYPES, WDocVirtualField> appFields = new HashMap<WDocVirtualField.TYPES, WDocVirtualField>();
			appFields.putAll(baseFields);
//			OLINK:原文地址,
			appFields.put(WDocVirtualField.TYPES.OLINK,
					new WDocVirtualField("原文地址", WDocVirtualField.TYPES.OLINK, "hourweb/Pubview.do?classid=$[CLASSID]&hourid=$[APPID]"));
			models.add(new WDocAppModel("课时", "HOUR", 1, appFields));
		}
//		{
//			Map<WDocVirtualField.TYPES, WDocVirtualField> appFields = new HashMap<WDocVirtualField.TYPES, WDocVirtualField>();
//			appFields.putAll(baseFields);
////			OLINK:原文地址,
//			appFields.put(WDocVirtualField.TYPES.OLINK,
//					new WDocVirtualField("原文地址", WDocVirtualField.TYPES.OLINK, "majorweb/Pubview.do?majorid=$[APPID]"));
//			models.add(new WDocAppModel("专业", "MAJOR", 1, appFields));
//		}
		return models;
	}

	/**
	 * 获得索引字段定义
	 * 
	 * @return
	 */
	public static List<WDocField> getFields() {
		List<WDocField> fields = new ArrayList<WDocField>();
		// name 中文名称
		// key 关键字字符唯一
		// storeis 是否存储
		// type 索引数据类型
		// sort 排序号
		// texttype 展示类型
		// sEARCHTYPE 检索类型
		// sortable 检索排序类型
		// boost 检索权重
		// maxlenght 最大存储长度
		fields.add(new WDocField("文档ID", "APPID", true, WDocField.TYPES.StringField, 1, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.none, 1, 128));

		fields.add(new WDocField("业务KEYID", "APPKEYID", true, WDocField.TYPES.StringField, 2, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.none, 1, 128));

		fields.add(new WDocField("权限KEY", "POPKEYS", true, WDocField.TYPES.TextField, 3, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.none, 1, 1024));

		fields.add(new WDocField("标题名称", "TITLE", true, WDocField.TYPES.TextField, 4, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.key, WDocField.SORTABLES.none, 2, 1024));

		fields.add(new WDocField("正文简介", "CONTENTS", true, WDocField.TYPES.TextField, 5, WDocField.TEXTTYPES.html,
				WDocField.SEARCHTYPES.key, WDocField.SORTABLES.none, 1, 1024));

		fields.add(new WDocField("分类名称", "TYPETITLE", true, WDocField.TYPES.TextField, 6, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.key, WDocField.SORTABLES.none, 1, 1024));

		fields.add(new WDocField("分类TREECODE", "TREECODE", true, WDocField.TYPES.TextField, 7, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.none, 1, 1024));

		fields.add(new WDocField("更新时间", "ETIME", true, WDocField.TYPES.TextField, 8, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.sort, 1, 64));

		fields.add(new WDocField("作者", "AUTHOR", true, WDocField.TYPES.TextField, 9, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.none, 1, 256));

		fields.add(new WDocField("标签", "TAG", true, WDocField.TYPES.TextField, 10, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.key, WDocField.SORTABLES.none, 2, 256));
		fields.add(new WDocField("预览图ID", "IMGID", true, WDocField.TYPES.TextField, 11, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.none, 1, 512));
		fields.add(new WDocField("预览图SECRET", "IMGSECRET", true, WDocField.TYPES.TextField, 12, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.none, 1, 64));
		fields.add(new WDocField("课程ID", "CLASSID", true, WDocField.TYPES.TextField, 11, WDocField.TEXTTYPES.text,
				WDocField.SEARCHTYPES.none, WDocField.SORTABLES.none, 1, 512));
		return fields;
	}

	/**
	 * 获得分类检索字典类型
	 * 
	 * @return
	 */
	public static WDocAppDic getAppDic_Catalog() {
		return new WDocAppDic("WLP_CATALOG","TREECODE", LIKETYPES.indexOf, ABLETYPES.all, SUMABLES.unable, "课程分类", 1, "CLASST,HOUR");
	}
}
